package com.example.hp.yuejian5.model;


import com.example.hp.yuejian5.RetrofitListener.RetrofitListener;
import com.example.hp.yuejian5.bean.AttentionBean;
import com.example.hp.yuejian5.service.AttentionMasterService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.hp.yuejian5.other.url.INDEXURL;

public class AttentionMasterModel {

    private Retrofit retrofit;
    private AttentionMasterService attentionMasterService;


    public AttentionMasterModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(INDEXURL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        attentionMasterService=retrofit.create(AttentionMasterService.class);
    }

    public void attentionMaster(String user_id, String master_id, final RetrofitListener listener)
    {
        Call<AttentionBean> call=attentionMasterService.attentionMaster(user_id,master_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }


}
